package com.pucheng.bracelet.ui.activity

import android.content.Intent
import android.os.Bundle
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.pucheng.bracelet.R
import com.pucheng.bracelet.app.base.BaseTitleActivity
import com.pucheng.bracelet.app.ext.KEY_FEEDBACK
import com.pucheng.bracelet.data.bean.FeedbackBean
import com.pucheng.bracelet.databinding.ActivityAboutBinding
import kotlinx.android.synthetic.main.activity_feedback_history.*
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel

/**
 * 我要反馈
 */
class FeedBackHistoryActivity : BaseTitleActivity<BaseViewModel, ActivityAboutBinding>() {
    private lateinit var mAdapter: BaseQuickAdapter<FeedbackBean, BaseViewHolder>
    override fun layoutId(): Int = R.layout.activity_feedback_history
    override fun initView(savedInstanceState: Bundle?) {
        val mData = mutableListOf<FeedbackBean>()
        mData.add(FeedbackBean("如何设置手环/手表时间？"))
        mData.add(FeedbackBean("如何查看手环/手表消息通知内容？"))
        mAdapter = object :
            BaseQuickAdapter<FeedbackBean, BaseViewHolder>(R.layout.item_feedback_history, mData) {
            override fun convert(holder: BaseViewHolder, item: FeedbackBean) {
                holder.setText(R.id.rv_feedback_name, item.title)
                    .setText(R.id.rv_feedback_tiem, item.create_time)
            }

        }
        rv_feedback_history.adapter = mAdapter
        mAdapter.setOnItemClickListener { _, _, position ->
            run {
                val mIntent =
                    Intent(this@FeedBackHistoryActivity, FeedbackDetailsActivity::class.java)
                mIntent.putExtra(KEY_FEEDBACK, mData[position])
                startActivity(mIntent)
            }
        }
    }

    override fun titleText(): String = getString(R.string.feedback_history)
}